//和为s的两个数字
//测试链接 https://leetcode.cn/problems/he-wei-sde-liang-ge-shu-zi-lcof/
public class TwoSum {
    public int[] twoSum(int[] price, int target) {
        int[] ans = new int[2];
        int left = 0;
        int right = price.length-1;

        while(left < right){
            int l = price[left];
            int r = price[right];
            if(l + r < target){
                left++;
            }else if(l + r > target){
                right--;
            }else {
                ans[0] =  l;
                ans[1] = r;
                break;
            }
        }
        return ans;
    }
}
